<?php
header('Content-Type: text/plain');
set_error_handler("handler");

$opts = array(
    'http' => array(
        'method' => "GET",
        'header' => "Accept-language: en\r\n" .
                    "Cookie: foo=bar\r\n"
    ),
    // "ssl"=>[
    //     "cafile" => "C:\Users\Administrator\Desktop\cacert.pem",
    // ],
);

$context = stream_context_create($opts);

$fp = fopen('https://www.baidu.com', 'r', false);
fpassthru($fp);
fclose($fp);

$fp = fopen('http://www.baidu.com', 'r', false);
fpassthru($fp);
fclose($fp);

function handler($errno,$errstr,$errfile,$errline)
{
    echo $errno.":".$errstr."\r\n";
}
